<template>
  <div class="disClassBox">
    <div class="btnBox height36">
      <el-button
        type="primary"
        style="float:right"
      >
        新增子分类
      </el-button>
    </div>
    <div class="content">
      <div class="leftTree">
        <el-tree
          :data="treeData"
          :props="defaultProps"
          @node-click="handleNodeClick"
        />
      </div>
      <div class="cntTab">
        <template>
          <el-table
            :data="tableData"
            stripe
            style="width: 100%"
          >
            <el-table-column
              type="index"
              label="编号"
              width="50"
              align="center"
            />
            <el-table-column
              prop="date"
              label="时间"
              width="180"
            />
            <el-table-column
              prop="title"
              label="标题"
            >
              <template slot-scope="scope">
                <span
                  class="tabDetail"
                  @click="handleDetail(scope.row)"
                >{{ scope.row.title }}</span>
              </template>
            </el-table-column>
          </el-table>
        </template>
        <div class="pageBox">
          <el-pagination
            background
            :current-page.sync="currentPage"
            :page-size="10"
            layout="prev, pager, next, jumper"
            :total="total"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      currentPage: 1,
      total: 0,
      treeData: [
        {
          label: '一级 1',
          children: [
            {
              label: '二级 1-1',
              children: [
                {
                  label: '三级 1-1-1'
                }
              ]
            }
          ]
        },
        {
          label: '一级 2',
          children: [
            {
              label: '二级 2-1',
              children: [
                {
                  label: '三级 2-1-1'
                }
              ]
            },
            {
              label: '二级 2-2',
              children: [
                {
                  label: '三级 2-2-1'
                }
              ]
            }
          ]
        },
        {
          label: '一级 3',
          children: [
            {
              label: '二级 3-1',
              children: [
                {
                  label: '三级 3-1-1'
                }
              ]
            },
            {
              label: '二级 3-2',
              children: [
                {
                  label: '三级 3-2-1'
                }
              ]
            }
          ]
        }
      ],
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      tableData: [
        {
          id: 1,
          date: '2016-05-02',
          title: '上海市普陀区金沙江路 1518 弄'
        },
        {
          id: 2,
          date: '2016-05-04',
          title: '上海市普陀区金沙江路 1517 弄'
        }
      ]
    }
  },
  methods: {
    handleNodeClick(data) {
      console.log(data)
    },
    handleCurrentChange(val) {
      console.log(val)
    }
  }
}
</script>
<style lang="scss" scoped>
.disClassBox {
  height: 100%;
  .height36 {
    height: 36px;
  }
  .content {
    display: flex;
    height: calc(100% - 56px);
    .leftTree {
      min-width: 200px;
      height: 100%;
      min-height: 550px;
      border: 1px solid #dfe6ec;
    }
    .cntTab {
      flex: 1;
      height: 100%;
      min-height: 550px;
      border: 1px solid #dfe6ec;
      border-left: none;
    }
  }
}
</style>
